package com.zhuiyun.project.api.video.mobileVideo.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.video.mobileVideo.entity.MobileVideo;
import com.zhuiyun.project.api.video.mobileVideo.model.*;
import com.zhuiyun.project.api.video.mobileVideo.service.MobileVideoService;
import com.zhuiyun.project.api.video.publishVideo.model.PublishVideoModel;
import com.zhuiyun.project.common.controller.BaseController;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName MobileVideoController
 * @Description 移动端视频管理
 * @Author qsh
 * @Date 2024/3/6 8:31
 **/
@RestController
@RequestMapping("/MobileVideo")
@Slf4j
public class MobileVideoController extends BaseController {
    @Autowired
    private MobileVideoService mobileVideoService;

    /**
    * @Author qsh
    * @Description 查询推荐页视频
    * @Date 2024/3/8 9:35
    * @Return com.zhuiyun.project.common.response.CommonResult

    */
    @GetMapping("/getMobileVideo")
    @ApiOperation(value = "查询推荐页视频接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "查询推荐页视频")
    public CommonResult getMobileVideo(PageRequest pageRequest){
        log.info("查询推荐页视频");
        return CommonResult.ok(mobileVideoService.MobileVideoList(pageRequest));
    }

    /**
     * @Author qsh
     * @Description 查询关注页视频
     * @Date 2024/3/8 9:35
     * @Return com.zhuiyun.project.common.response.CommonResult

     */
    @GetMapping("/getMobileVideoFollow/{redisKey}")
    @ApiOperation(value = "查询关注页视频接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "查询关注页视频")
    public CommonResult getMobileVideoFollow(@PathVariable("redisKey") String redisKey,@RequestParam PageRequest pageRequest){
        log.info("查询关注页视频");
        return CommonResult.ok(mobileVideoService.MobileVideoFollow(redisKey,pageRequest));
    }

    /**
    * @Author qsh
    * @Description 查询用户点赞视频ID
    * @Date 2024/3/18 15:40
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param redisKey
    */
    @GetMapping("/UserLikeVideos/{redisKey}")
    @ApiOperation(value = "查询用户点赞视频ID接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "查询用户点赞视频ID")
    public CommonResult LikeList(@PathVariable("redisKey") String redisKey){
        log.info("查询用户点赞视频ID");
        return CommonResult.ok(mobileVideoService.LikeList(redisKey));
    }

    /**
     * @Author qsh
     * @Description 查询用户收藏视频ID
     * @Date 2024/3/18 15:40
     * @Return com.zhuiyun.project.common.response.CommonResult
     * @param redisKey
     */
    @GetMapping("/UserCollectVideos/{redisKey}")
    @ApiOperation(value = "查询用户收藏视频ID接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "查询用户收藏视频ID")
    public CommonResult collectList(@PathVariable("redisKey") String redisKey){
        log.info("查询用户收藏视频ID");
        return CommonResult.ok(mobileVideoService.collectList(redisKey));
    }

    /**
     * @Author qsh
     * @Description 查询用户关注UpID
     * @Date 2024/3/18 15:40
     * @Return com.zhuiyun.project.common.response.CommonResult
     * @param redisKey
     */
    @GetMapping("/FollowUp/{redisKey}")
    @ApiOperation(value = "查询用户关注UpID接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "查询用户关注UpID")
    public CommonResult FollowUp(@PathVariable("redisKey") String redisKey){
        log.info("查询用户关注UpID");
        return CommonResult.ok(mobileVideoService.followList(redisKey));
    }

    /**
    * @Author qsh
    * @Description 主页关注
    * @Date 2024/3/14 9:32
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param followWithInterestModel
    */
    @PostMapping("/UserFollow")
    @ApiOperation(value = "主页关注接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "关注视频发布者")
    public CommonResult UserFollow(@RequestBody FollowWithInterestModel followWithInterestModel) throws CommonException {
        log.info("关注视频发布者");
        return CommonResult.ok(mobileVideoService.UserFollow(followWithInterestModel));
    }

    /**
    * @Author qsh
    * @Description 点赞视频
    * @Date 2024/3/14 9:33
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param userVideoLikeModel
* @param idx
    */
    @PostMapping("/UserLike/{idx}")
    @ApiOperation(value = "点赞视频接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "点赞视频")
    public CommonResult UserLike(@RequestBody UserVideoLikeModel userVideoLikeModel,@PathVariable("idx") Integer idx) throws CommonException {
        log.info("点赞视频");
        return CommonResult.ok(mobileVideoService.UserLike(userVideoLikeModel,idx));
    }

    /**
    * @Author qsh
    * @Description 收藏视频
    * @Date 2024/3/14 9:33
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param userVideoCollectModel
* @param idc
    */
    @PostMapping("/UserFavorites/{idc}")
    @ApiOperation(value = "收藏视频接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "收藏视频")
    public CommonResult UserFavorites(@RequestBody UserVideoCollectModel userVideoCollectModel, @PathVariable("idc") Integer idc) throws CommonException {
        log.info("收藏视频");
        return CommonResult.ok(mobileVideoService.UserFavorites(userVideoCollectModel,idc));
    }

    /**
    * @Author qsh
    * @Description 持久化点赞数据
    * @Date 2024/3/14 9:33
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param videoIndexing
    */
    @PutMapping("/Likes/{videoIndexing}")
    @ApiOperation(value = "持久化点赞数据接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "持久化点赞数据")
    public CommonResult Likes(@RequestBody MobileVideo mobileVideo,@PathVariable("videoIndexing") Integer videoIndexing) throws CommonException {
        log.info("持久化点赞数据");
        return CommonResult.ok(mobileVideoService.Likes(mobileVideo,videoIndexing));
    }

    /**
     * @Author qsh
     * @Description 持久化收藏数据
     * @Date 2024/3/14 9:33
     * @Return com.zhuiyun.project.common.response.CommonResult
     * @param videoIndexing
     */
    @PutMapping("/collect/{videoIndexing}")
    @ApiOperation(value = "持久化收藏数据接口")
    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "持久化收藏数据")
    public CommonResult collect(@RequestBody MobileVideo mobileVideo,@PathVariable("videoIndexing") Integer videoIndexing) throws CommonException {
        log.info("持久化收藏数据");
        return CommonResult.ok(mobileVideoService.collect(mobileVideo,videoIndexing));
    }

    /**
    * @Author qsh
    * @Description 查询持久化视频数据
    * @Date 2024/3/14 9:33
    * @Return com.zhuiyun.project.common.response.CommonResult

    */
//    @GetMapping("/VideoLikeCounts")
//    @ApiOperation(value = "查询持久化视频数据接口")
//    @OptLog(modular = "移动端视频管理", type = CommonConstants.SELECT, describe = "查询持久化视频数据")
//    public CommonResult VideoLikeCounts(){
//        log.info("查询持久化视频数据");
//        return CommonResult.ok(mobileVideoService.VideoLikeCounts());
//    }
}
